package logic

import (
	"context"
	"shop-ease/model"

	"shop-ease/shoprpc/internal/svc"
	"shop-ease/shoprpc/shoprpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type LikeListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLikeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LikeListLogic {
	return &LikeListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *LikeListLogic) LikeList(in *shoprpc.LikeListRequest) (*shoprpc.LikeListResponse, error) {
	// todo: add your logic here and delete this line

	var likes []model.Like
	model.DB.Debug().Find(&likes)
	var LikeList []*shoprpc.LikeList
	for _, like := range likes {

		list := shoprpc.LikeList{
			UserId: int64(like.UserId),
			Num:    int64(like.Num),
		}
		LikeList = append(LikeList, &list)
	}
	return &shoprpc.LikeListResponse{
		List: LikeList,
	}, nil
}
